package string;

import java.util.Arrays;

/**
 * String[] spilt(String )
 */
public class SplitDemo {
    public static void main(String[] args) {
        String line = "abc123def456ghi";
        String []data = line.split("[0-9]+");
        System.out.println(Arrays.toString(data));

        line = "123.456.789";
        data = line.split("\\.");
        System.out.println(Arrays.toString(data));

        //最开始就是可拆分项,那么数组第1个元素为空字符串----""
        //如果连续两个(两个以上),可拆分项,那么中间也会拆出一个空字符串---""
        //如果末尾连续多个可拆分项,那么拆出的空字符串被忽略(不要了)
        line = ".123..456.789......";
        data = line.split("\\.");
        System.out.println(Arrays.toString(data));

        line = ".......123.456...789...";
        data = line.split("\\.");
        System.out.println(Arrays.toString(data));
    }
}
